Hệ thống quản lý phòng khám trực tuyến bằng PHP
1 <?php
2 $currDir = dirname(__FILE__);
3 require("{$currDir}/incCommon.php");
4 $GLOBALS['page_title'] = $Translation['data records'];
5 include("{$currDir}/incHeader.php");
6
7 // process search
8 $memberID = new Request('memberID', 'strtolower');
9 $groupID = max(0, intval($_GET['groupID']));
10 $tableName = new Request('tableName');
11 $page = max(1, intval($_GET['page']));
12
13 // process sort
14 $sortDir = ($_GET['sortDir'] == 'desc' ? 'desc' : '');
15 $sort = makeSafe($_GET['sort']);
16 if($sort != 'dateAdded' && $sort != 'dateUpdated'){ // default sort is newly created first
17 $sort = 'dateAdded';
18 $sortDir = 'desc';
19 }
20
21 if($sort){
22 $sortClause = "order by {$sort} {$sortDir}";
23 }
24
25 if($memberID->sql != ''){
26 $where .= ($where ? " and " : "") . "r.memberID like '{$memberID->sql}%'";
27 }
28
29 if($groupID){
30 $where .= ($where ? " and " : "") . "g.groupID='{$groupID}'";
31 }
32
33 if($tableName->sql != ''){
34 $where .= ($where ? " and " : "") . "r.tableName='{$tableName->sql}'";
35 }
36
37 if($where){
38 $where = "where {$where}";
39 }
40
41 $numRecords = sqlValue("select count(1) from membership_userrecords r left join membership_groups g on r.groupID=g.groupID {$where}");
42 $noResults = false;
43 if(!$numRecords){
44 echo "<div class=\"alert alert-warning\">{$Translation['no matching results found']}</div>";
45 $noResults = true;
46 $page = 1;
47 }
48
49 if($page > ceil($numRecords / $adminConfig['recordsPerPage']) && !$noResults){
50 redirect("admin/pageViewRecords.php?page=" . ceil($numRecords/$adminConfig['recordsPerPage']));
51 }
52
53 $start = ($page - 1) * $adminConfig['recordsPerPage'];
54
55 ?>
56 <div class="page-header"><h1><?php echo $Translation['data records'] ; ?></h1></div>
57
58 <table class="table table-striped table-bordered table-hover">
59 <thead>
60 <tr>
61 <th colspan="7">
62 <form class="form-inline" method="get" action="pageViewRecords.php" class="form-horizontal">
63 <input type="hidden" name="page" value="1">
64
65 <div class="form-group">
66 <label for="groupID" class="control-label"><?php echo $Translation["group"]; ?></label>
67 <?php echo htmlSQLSelect("groupID", "select groupID, name from membership_groups order by name", $groupID); ?>
68 </div>
69 <div class="form-group">
70 <label for="memberID" class="control-label"><?php echo $Translation["member username"] ; ?></label>
71 <input type="text" class="form-control" id="memberID" name="memberID" value="<?php echo $memberID->attr; ?>">
72 </div>
73 <div class="form-group">
74 <label for="tableName" class="control-label"><?php echo $Translation['show records'] ; ?></label>
75 <?php
76 $tables = array_merge(array('' => $Translation['all tables']), getTableList(true));
77 $arrFields = array_keys($tables);
78 $arrFieldCaptions = array_values($tables);
79 echo htmlSelect('tableName', $arrFields, $arrFieldCaptions, $tableName->raw);
80 ?>
81 </div>
82 <div class="form-group">
83 <label for="sort" class="control-label"><?php echo $Translation['sort records'] ; ?></label>
84 <?php
85 $arrFields = array('dateAdded', 'dateUpdated');
86 $arrFieldCaptions = array( $Translation['date created'] , $Translation['date modified'] );
87 echo htmlSelect('sort', $arrFields, $arrFieldCaptions, $sort);
88 ?>
89 <span class="hspacer-md"></span>
90 <?php
91 $arrFields=array('desc', '');
92 $arrFieldCaptions = array( $Translation['newer first'] , $Translation['older first'] );
93 echo htmlSelect('sortDir', $arrFields, $arrFieldCaptions, $sortDir);
94 ?>
95 </div>
96 <div class="form-group">
97 <button type="submit" class="btn btn-primary"><i class="glyphicon glyphicon-search"></i> <?php echo $Translation['find'] ; ?></button>
98 <button type="button" id="reset-search" class="btn btn-warning"><i class="glyphicon glyphicon-remove"></i> <?php echo $Translation['reset'] ; ?></button>
99 </div>
100 </form>
101 </th>
102 </tr>
103 <tr>
104 <th> </td>
105 <th><?php echo $Translation['username'] ; ?></th>
106 <th><?php echo $Translation["group"] ; ?></th>
107 <th><?php echo $Translation["table"] ; ?></th>
108 <th><?php echo $Translation['created'] ; ?></th>
109 <th><?php echo $Translation['modified'] ; ?></th>
110 <th><?php echo $Translation['data'] ; ?></th>
111 </tr>
112 </thead>
113 <tbody>
114 <?php
115
116 $res = sql("select r.recID, r.memberID, g.name, r.tableName, r.dateAdded, r.dateUpdated, r.pkValue from membership_userrecords r left join membership_groups g on r.groupID=g.groupID $where $sortClause limit $start, " . $adminConfig['recordsPerPage'], $eo);
117 while($row = db_fetch_row($res)){
118 ?>
119 <tr>
120 <td class="text-center">
121 <a href="pageEditOwnership.php?recID=<?php echo $row[0]; ?>" title="<?php echo $Translation['change record ownership'] ; ?>"><i class="glyphicon glyphicon-user"></i></a>
122 <a href="pageDeleteRecord.php?recID=<?php echo $row[0]; ?>" onClick="return confirm('<?php echo $Translation['sure delete record'] ; ?>');" title="<?php echo $Translation['delete record'] ; ?>"><i class="glyphicon glyphicon-trash text-danger"></i></a>
123 </td>
124 <td><?php echo $row[1]; ?></td>
125 <td><?php echo $row[2]; ?></td>
126 <td><?php echo $row[3]; ?></td>
127 <td class="<?php echo ($sort == 'dateAdded' ? 'warning' : '');?>"><?php echo @date($adminConfig['PHPDateTimeFormat'], $row[4]); ?></td>
128 <td class="<?php echo ($sort == 'dateUpdated' ? 'warning' : '');?>"><?php echo @date($adminConfig['PHPDateTimeFormat'], $row[5]); ?></td>
129 <td>
130 <a href="#" class="view-record" data-record-id="<?php echo $row[0]; ?>"><i class="glyphicon glyphicon-search hspacer-md"></i></a>
131 <?php echo substr(getCSVData($row[3], $row[6]), 0, 80) . " ... "; ?>
132 </td>
133 </tr>
134 <?php
135 }
136 ?>
137 </tbody>
138 <tfoot>
139 <tr>
140 <td colspan="7" style="padding: .3em;">
141 <table width="100%" cellspacing="0">
142 <tr>
143 <th class="text-left flip" style="width: 25%;">
144 <?php if($start){ ?>
145 <a href="pageViewRecords.php?groupID=<?php echo $groupID; ?>&memberID=<?php echo $memberID->url; ?>&tableName=<?php echo $tableName->url; ?>&page=<?php echo ($page > 1 ? $page - 1 : 1); ?>&sort=<?php echo $sort; ?>&sortDir=<?php echo $sortDir; ?>" class="btn btn-default"><?php echo $Translation['previous'] ; ?></a>
146 <?php } ?>
147 </th>
148 <th class="text-center">
149 <?php
150 $record1 = $start + 1;
151 $record2 = $start + db_num_rows($res);
152 $originalValues = array('<RECORDNUM1>', '<RECORDNUM2>', '<RECORDS>');
153 $replaceValues = array($record1, $record2, $numRecords);
154 echo str_replace($originalValues, $replaceValues, $Translation['displaying records']);
155 ?>
156 </th>
157 <th class="text-right flip" style="width: 25%;">
158 <?php if($record2 < $numRecords){ ?>
159 <a href="pageViewRecords.php?groupID=<?php echo $groupID; ?>&memberID=<?php echo $memberID->url; ?>&tableName=<?php echo $tableName->url; ?>&page=<?php echo ($page<ceil($numRecords/$adminConfig['recordsPerPage']) ? $page+1 : ceil($numRecords/$adminConfig['recordsPerPage'])); ?>&sort=<?php echo $sort; ?>&sortDir=<?php echo $sortDir; ?>" class="btn btn-default"><?php echo $Translation['next'] ; ?></a>
160 <?php } ?>
161 </th>
162 </tr>
163 </table>
164 </td>
165 </tr>
166 </tfoot>
167 </table>
168
169 <div class="modal fade" tabindex="-1" id="view-record-modal">
170 <div class="modal-dialog modal-lg">
171 <div class="modal-content">
172 <button type="button" class="close hspacer-md vspacer-md" data-dismiss="modal">×</button>
173 <div class="modal-body" style="-webkit-overflow-scrolling:touch !important; overflow-y: auto;">
174 <iframe width="100%" height="100%" sandbox="allow-forms allow-scripts allow-same-origin" src="" id="view-record-iframe"></iframe>
175 </div>
176 </div>
177 </div>
178 </div>
179
180 <style>
181 .form-inline .form-group{ margin: .5em 1em; }
182 </style>
183
184 <script>
185 $j(function(){
186 $j('.view-record').click(function(){
187 var recID = $j(this).data('record-id');
188 $j('#view-record-iframe').attr('src', 'pagePrintRecord.php?recID=' + recID);
189 $j('#view-record-modal').modal('show');
190 $j('#view-record-modal .modal-body').height($j(window).height() * 0.7);
191
192 return false;
193 });
194
195 $j('#reset-search').click(function(){
196 window.location = 'pageViewRecords.php';
197 });
198
199 $j('#tableName, #groupID, #sort, #sortDir').addClass('form-control');
200 })
201 </script>
202
203 <?php
204 include("{$currDir}/incFooter.php");